package com.service.impl;

import com.bean.entity.ProductInfomation;
import com.bean.vo.ProductInfomationQueryVo;
import com.dao.ProductInfomationMapper;
import com.service.ProductInfomationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;

/**
 * 产品信息管理实现
 */
@Service
public class ProductInfomationServiceImpl implements ProductInfomationService {
    @Autowired
    ProductInfomationMapper pid;

//    @Override
//    public List<ProductInfomationQueryVo> QueryAll(ProductInfomationQueryVo piqv) {
////        List<ProductInfomationQueryVo> list = pid.select(piqv);
//        int count = pid.selectCount(piqv);
//        piqv.setPage_size(count);
//        List<ProductInfomationQueryVo> list = pid.selectByPage(piqv);
//        return list;
//    }

    @Override
    public List<ProductInfomationQueryVo> QueryAll(ProductInfomationQueryVo piqv) {
        List<ProductInfomationQueryVo> list = pid.selectByPage(piqv);
        return list;
    }

    @Override
    public int upDate(ProductInfomationQueryVo piqv) {
        ProductInfomation pi = piqv.getPi();
        int count = pid.update(pi);
        return count;
    }

    @Override
    public int delete(ProductInfomationQueryVo piqv) {
        int count = pid.delete(piqv);
        return count;
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public int add(ProductInfomationQueryVo piqv) {
        ProductInfomation pi = piqv.getPi();
        int count = pid.insertMain(pi);
        return count;
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public int fakeDelete(ProductInfomationQueryVo piqv) {
        int count = pid.fakeDelete(piqv);
        return count;
    }

    @Override
    public int count(ProductInfomationQueryVo piqv) {
        int count = pid.selectCount(piqv);
        return count;
    }
}
